<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<script src="${ctxPath!}/js/base/jquery-1.8.3.min.js"></script>
<script src="${ctxPath!}/js/base/layer/layer.js"></script>
<link rel="stylesheet" href="${ctxPath!}/js/layui/css/layui.css">
<script src="${ctxPath!}/js/layui/layui.js"></script>
<script src="${ctxPath!}/js/base/common.js"></script>
<script>
    var basePath="${ctxPath!}";
    //打开遮罩层
    function showMask(){
        var index = layer.load(1,{shade:[0.2,'#000']});
        return index;
    }
    //关闭遮罩层
    function closeMask(index){
        if(index){
            layer.close(index);
        }else{
            layer.closeAll();
        }
    }
    /**
     * 全局监听ajax发送请求
     */
    $(function(){
        var openIndex;
        //全局监听开始请求
        $(document).ajaxStart(function() {
            openIndex=showMask();
        });
        //全局监听请求完成
        $(document).ajaxComplete(function(){
            closeMask(openIndex);
        });
        //全局监听请求成功
        $(document).ajaxSuccess(function(event,jqXHR, ajaxOptions,data) {
            if(data&&data.code){
                if(data.code=="login_again"){
                    layer.msg(data.msg,{
                        icon: 2
                    });
                    setTimeout(function(){
                        window.location.href=basePath+"/loginPage";
                    }, 2000);
                }
            }
        });
        //全局监听请求失败
        $(document).ajaxError(function(event,jqXHR,ajaxOptions,data){

        });

    })

</script>
<style>
html,body{
    height:100%;
}
</style>